
let data = [
  {name: '先进制造业', value: [{name: '产业1', value: 20}, {name: '产业2', value: 20}, {name: '产业3', value: 20}]},
  {name: '二大业', value: [{name: '产业5', value: 10}, {name: '产业6', value: 10}, {name: '产业7', value: 10}]},
  {name: '都市现代业', value: [{name: '产业9', value: 10}, {name: '产业10', value: 10}, {name: '产业11', value: 10}]}
];

let parents = data.map(d => ({name: d.name, value: d.value.reduce((a, b) => (a + b.value), 0)}));
let colorP = ['#f0f', '#00f', '#0ff'];

// 子类颜色使用父类颜色，在配置项修改透明度
let children = data.reduce((a, b, i) => a.concat(b.value.map(e => {
  e['itemStyle'] = {color: colorP[i]}; return e;})), []);

export let option = {
  title: {
    text: 'Alcohol Consumption Per Country',
    subtext: "The World Health Organization (WHO)'s breakdown of per capita alcohol\nconsumption among adults over 15.",
    sublink: 'https://opendata.socrata.com/Government/Alcohol-Consumption-Per-Country/hj43-2bpj',
    textStyle: {
      fontSize: 30
    }
  },
  visualMap: {
    min: 0,
    max: 15,
    formatter: '{value} liters / captita'
  },
  // geo: [{
  //   map: 'world',
  //   label: {
  //     normal: {
  //       show: true,
  //       formatter: 'dd'
  //     }
  //   }
  // }],
  series: [{
    type: 'map',
    // geoIndex: 0,
    mapType: 'world',
    label: {
      normal: {
        show: true,
        formatter: 'dd'
      }
    },
    data: []
  }]
};

export const name = 'pieTwo';
